%macro get_f1099k;

	
	proc printto log = "&logdir/get_f1099k.txt" new;
	run;
	

		/****************************
		*	Get the tins 			*
		*	into 'tinlist'			*
		****************************/
		%make_tinlist;

		/****************************************
		*										*
		*			Start PROC SQL				*
		*										*
		****************************************/
		proc sql noprint;
		[connection details redacted]
			create table rlib.f1099k as
			select * from connection to iq 
			(
			select
				sum(coalesce(b.[redacted],0)) as receipts_f1099k,
				sum(coalesce(b.[redacted],0)) as f1099k_wh,
				a.person_id
			from #tinlist as a
				inner join [redacted] as b
					on(a.person_id = b.[redacted])
			where b.[redacted] = &base_yr
				and b.[redacted] <= 4
			group by a.person_id
			order by a.person_id
			);
			disconnect from iq;
			quit;



	proc printto;
	run;
%mend;
